<?php
//
//	file: includes/log/plug_advlog_stats.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 31 $
//	$Date: 2008-07-21 03:08:30 +0000 (Mon, 21 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: plug for advlog to class_stats_online

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

class advlog_stats
{
	// adds to session fields for display
	function read(&$session_fields, &$user_fields)
	{
		$session_fields[] = 'session_user_agent';

		return;
	}

	function display($mode='', $row='', $switch='')
	{
		global $template, $user;

		// check auth
		if (!$user->auth(POST_GROUPS_URL, AUTH_LOG_VIEWIP))
		{
			return;
		}

		if ($mode == '')
		{
			$template->assign_vars(array(
				'L_WHOIS' => $user->lang('Whois'),
				'L_IP' => $user->lang('IP'),
				'L_BROWSER' => $user->lang('Browser'),
			));

			return;
		}

		$ipmode = _read('ipmode', TYPE_NO_HTML, 'ip', array('ip', 'lookup'));
		$ip = _read('ip', TYPE_NO_HTML, decode_ip($row['session_ip']));

		$host = ($ipmode == 'lookup' && $ip) ? gethostbyaddr($ip) : $ip;
		$ipmode = ($ipmode != 'lookup') ? 'lookup' : 'ip';

		$template->assign_lastblock_vars($switch, array(
			'IP_ADDRESS' => $host,
			'USER_AGENT' => htmlspecialchars($row['session_user_agent']),
			'U_HOSTNAME_LOOKUP' => $config->url('viewonline', array('ipmode' => $ipmode, 'ip' => $ip), true),
		));

		$template->set_switch($switch . '.switch_log_viewip');

		return;
	}
}

?>